import 'package:Sayagh/tablepress/Categories.dart';
import 'package:flutter/material.dart';
import 'package:Sayagh/tablepress/csv.dart';
import 'package:Sayagh/i18n/i18nLocale.dart';
import 'package:Sayagh/Configs.dart';

class Cities extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    String citiessUrl = "$cities";
    Future<List<List>> citiessList = csv(citiessUrl);

    return Scaffold(
    appBar: AppBar(title: asnafHeader,),
//      appBar: AppBar(title: Text(i18nLocale[ourLocale]['citiess']),),
      body: FutureBuilder(
        future: citiessList,
        builder: (BuildContext context, AsyncSnapshot snapshot) {
          if (snapshot.data == null) {
            return Card(
              child: Text(i18nLocale[ourLocale]['reciving']),
            );
          }
          else {
            return ListView.builder(
                itemCount: snapshot.data[1].length - 1,
                itemBuilder: (BuildContext context, int index) {
                  List<String> cities = snapshot.data[1][index];
                  
                  Color color = Colors.greenAccent;
                  if (index % 2 == 0) {
                    color = Colors.lightGreen;
                  }


                  return Card(
                      color: color,
                      child: InkWell(child:  Text(cities[1],textDirection: TextDirection.rtl,textAlign: TextAlign.center,

                      ),
                      onTap: ()=> Navigator.push(context, MaterialPageRoute(builder: (context) => Categories(cities[3],cities[2],cities[1]))),)
                  );
                }
            );
          }
        },
      ),


    );
  }
}